using System.Collections.Generic;
using System.Linq;
using System.Windows.Data;
using Common;
using Infragistics.Win.UltraWinGrid;
using SWellPlate;

namespace MainView.MainControls
{
	internal class CustomMergedCellEvaluator_AmoyDx : IMergedCellEvaluator
	{
		private CollectionViewSource _view;

		public CustomMergedCellEvaluator_AmoyDx(CollectionViewSource view)
		{
			_view = view;
		}

		public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column)
		{
			bool flag = false;
			List<ChartData> list = _view.View.Cast<ChartData>().ToList();
			if (row1.Index >= list.Count || row2.Index >= list.Count || list[row1.Index].WellCell.Well.Sample == null || list[row1.Index].WellCell.Well.Sample != list[row2.Index].WellCell.Well.Sample)
			{
				return false;
			}
			flag = row1.Cells[column.Index].Value.Equals(row2.Cells[column.Index].Value);
			if (ConfigReader.GetInstance().GetMergerSampleResultFromIni() != 1)
			{
				flag = flag && list[row1.Index].WellCell.Well == list[row2.Index].WellCell.Well;
			}
			return flag;
		}
	}
}
